# -*- coding: UTF-8 -*-
import matplotlib.pyplot as plt
import numpy as np
plt.figure(1)
plt.subplot(221)
plt.plot([4,2,1,3,10,7])
plt.ylabel('some nunbers')

plt.figure(2)
plt.subplot(221)
plt.plot([1,2,3,4],[1,5,10,20],'ro')
plt.axis([0,6,0,50])

plt.figure(3)
plt.subplot(221)
t = np.arange(0., 5., 0.1)
plt.plot(t, 'r--', t**2, 'bs', t**3, 'g^')


def f(t):
    return np.exp(-t) * np.cos(2*np.pi*t)

t1 = np.arange(0.0, 5.0, 0.1)
t2 = np.arange(0.0, 5.0, 0.02)
t = np.arange(0., 5., 0.1)

plt.figure(4)
plt.subplot(221)
plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k')

plt.subplot(222)
plt.plot(t2, np.cos(2*np.pi*t2), 'g^')

plt.figure(5)
plt.subplot(221)
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.plot(t, 'r--', t**4, 'bs', t**6, 'g^')
plt.xlabel('my data', fontsize=14, color='red')
plt.title('function')
plt.text(5.0,1.0,'not')
plt.grid(True)

plt.figure(6)
np.random.seed(19680801)

mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)
n, bins, patches = plt.hist(x, 100, normed=0.1, facecolor='r', alpha=0.5)
#柱状图hist             X为数组，100是宽度，facecolor是颜色，alpha是透明度
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title('Histogram of IQ')
plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
plt.axis([40, 160, 0, 0.03])
plt.grid(True)

plt.figure(7)

t = np.arange(0.0, 5.0, 0.01)
s = np.cos(2*np.pi*t)
line, = plt.plot(t, s, lw=2)

plt.annotate('local max', xy=(2, 1), xytext=(3, 1.5),
            arrowprops=dict(facecolor='black', shrink=0.05),
            )

plt.ylim(-2,2)


plt.show()     